<template>
  <div class="list-table">
    <div class="area-header">
      <span class="area-header-title">{{ $t('接收人列表') }}</span>
    </div>
    <el-table
      v-loading="loading"
      :data="msgSendSituationList"
      :model="queryParams"
      border
      tooltip-effect="darkTable"
      style="width:100%"
      height="600"
    >
      <el-table-column :label="$t('序号')" type="index" align="center" show-overflow-tooltip width="50">
        <template slot-scope="scope">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('接收用户')" align="center" prop="userNickName" />
      <el-table-column :label="$t('是否已读')" align="center" prop="status" :formatter="statusFormat" />
      <el-table-column :label="$t('查看时间')" align="center" prop="updateTime" width="180">
        <template slot-scope="scope">
          <span v-if="scope.row.status === 'Y'">{{ parseTime(scope.row.updateTime,'{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getMsgSendSituation } from '@/api/system/message/msgSend'

export default {

  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 【系统通知-查看详情】表格数据
      msgSendSituationList: [],
      // 发布时间 参数
      releaseTimes: [],
      // 通知状态 字典
      statusOptions: [],
      // 查询参数
      queryParams: {
        id: undefined,
        userId: undefined,
        status: undefined,
        dataId: undefined,
        nickName: undefined,
        pageNum: 1,
        pageSize: 10
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    }
  },
  created() {
    this.getList()
    // 是否 字典sys_yes_no字典翻译
    this.getDicts('sys_yes_no').then(response => {
      this.statusOptions = response.data
    })
  },
  methods: {
    // 查询通知列表
    getList() {
      this.loading = true
      getMsgSendSituation(this.queryParams).then(response => {
        this.msgSendSituationList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    findHandle(id) {
      this.queryParams.dataId = id
      this.getList()
    },
    // 表单重置
    reset() {
      this.form = {}
      this.resetForm('form')
    },
    // 通知状态字典翻译
    statusFormat(row) {
      return this.selectDictLabels(this.statusOptions, row.status)
    }
  }
}
</script>
